package zj.playCard;

import java.util.Random;

public class PokerEntity implements CardEntity {

    static char[] pokerCard = new char[54];
    static String[] pokerCardName = new String[54];

    public static void INIT_CARDS() {

	for (int i = 0; i < pokerCard.length; i++) {
	    pokerCard[i] = (char) (card + i);
//	    pokerCardName[i] = PokerEnum.getShape(i);// 图形版本
	    pokerCardName[i] = PokerEnum.getNameByOrdinal(i);// 文字版本
	}
    }

    public static String getCardName(char index) {
	for (int i = 0; i < pokerCard.length; i++)
	    if (pokerCard[i] == index)
		return pokerCardName[i];

	return "";
    }

    public static char[] INIT_RANDOM() {
	INIT_CARDS();
	Random rn = new Random();
	int i = 53;
	char[] ca = pokerCard.clone();
	while (i != 0) {
	    int rand = rn.nextInt(i);

	    char temp = ca[i];
	    ca[i] = ca[rand];
	    ca[rand] = temp;

	    i--;
	}

	return ca;
    }

    public static void main(String[] args) {
	PokerEntity pk = new PokerEntity();
	pk.INIT_CARDS();
	char[] chars = pk.INIT_RANDOM();
	for (char c : chars) {
	    System.out.print(pk.getCardName(c) + " | ");

	}

    }

}
